/**
 * @Author : yangsanjin
 * @Date: 2024-10-10 10:55
 *
 * 持久化数据
 * npm i pinia-plugin-persistedstate
 * https://prazdevs.github.io/pinia-plugin-persistedstate/zh/guide/config.html
 */
import {defineStore} from 'pinia'
import { USE_SYSTEM } from './fixedValue.js'
export default defineStore('system', {
    state:()=>{
        return {
            //当前的布局类型 TopAndBottomLayout UpDownLayout
            layout:'UpDownLayout',
            //主题风格
            theme:'default',
            //表单缓存
            cache:false,
            //左侧菜单栏宽度
            menuWidth:210,
            //菜单风格inline(内嵌),vertical(侧边垂直),allMenu(侧边全显)
            menuStyle:'allMenu'
        }
    },
    getters:{
        systemHeme(){
            document.documentElement.dataset.jpaasTheme = this.theme ;
            return this.theme;
        }
    },
    actions:{
        setStates(key,value){
            this[key] = value ;
        }
    },
    //开启状态持久化，缓存在localStorage中
    persist: {
        enabled: true,
        key: USE_SYSTEM,
        storage: window.localStorage,
    }
})
